home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 2.9 KB | 83 lines | [TEXT/CWIE] |
- // RedBlackTreeLoop.h
-
- #ifndef RedBlackTreeLoop_h
- #define RedBlackTreeLoop_h
-
- #ifndef RedBlackNode_h
- #include "RedBlackNode.h"
- #endif
- #ifndef RedBlackTree_h
- #include "RedBlackTree.h"
- #endif
- #ifndef TreeLoop_h
- #include "TreeLoop.h"
- #endif
-
- template < class Key, class Target >
- class RedBlackTreeLoop: private TreeLoop
- {
- typedef RedBlackNode<Key,Target> LinkType;
- typedef RedBlackTree<Key,Target> HeadType;
- typedef RedBlackTreeLoop<Key,Target> LoopType;
- typedef TreeLoop Inherited;
-
- private:
- static const LinkType *DownCast( const TreeNode *n )
- {
- return static_cast< const LinkType* >( n );
- }
-
- static const HeadType& DownCast( const Tree& n )
- {
- return static_cast< const HeadType& >( n );
- }
-
- public:
- RedBlackTreeLoop( const HeadType& h ) : Inherited( h ) {}
- RedBlackTreeLoop( const HeadType& h, AtStart ) : Inherited( h, atStart ) {}
- RedBlackTreeLoop( const HeadType& h, AtEnd ) : Inherited( h, atEnd ) {}
- RedBlackTreeLoop( const HeadType& h, Nowhere ) : Inherited( h, nowhere ) {}
- RedBlackTreeLoop( const HeadType& h, const LinkType& p ) : Inherited( h, p ) {}
- RedBlackTreeLoop( const HeadType& h, Before, const LinkType& p ) : Inherited( h, before, p ) {}
- RedBlackTreeLoop( const HeadType& h, After, const LinkType& p ) : Inherited( h, after, p ) {}
- RedBlackTreeLoop( const HeadType& h, BeforeStart ) : Inherited( h, beforeStart ) {}
- RedBlackTreeLoop( const HeadType& h, AfterEnd ) : Inherited( h, afterEnd ) {}
-
- const HeadType& Owner() const { return DownCast( Inherited::Owner() ); }
-
- Inherited::Finished;
- Inherited::Unfinished;
-
- Inherited::MoveToFinish;
- Inherited::MoveToFirst;
- Inherited::MoveToLast;
- Inherited::MoveBeforeFirst;
- Inherited::MoveAfterLast;
-
- void MoveTo( const LinkType& p ) { Inherited::MoveTo( p ); }
- void MoveBefore( const LinkType& p ) { Inherited::MoveBefore( p ); }
- void MoveAfter( const LinkType& p ) { Inherited::MoveAfter( p ); }
-
- bool operator==( const LoopType& r ) const { return Inherited::operator==( r ); }
- bool operator!=( const LoopType& r ) const { return Inherited::operator!=( r ); }
-
- bool operator==( const LinkType& r ) const { return Inherited::operator==( r ); }
- bool operator!=( const LinkType& r ) const { return Inherited::operator!=( r ); }
-
- Inherited::Null;
- const LinkType *Position() const { return DownCast( Inherited::Position() ); }
-
- const LinkType *Next() const { return DownCast( Inherited::Next() ); }
- const LinkType *Previous() const { return DownCast( Inherited::Previous() ); }
-
- Target& operator*() const { return **DownCast( Inherited::operator->() ); }
- Target *operator->() const { return &**DownCast( Inherited::operator->() ); }
-
- void operator++() { Inherited::operator++(); }
- void operator++(int) { Inherited::operator++(0); }
- void operator--() { Inherited::operator--(); }
- void operator--(int) { Inherited::operator--(0); }
- };
-
- #endif
-